define(
    ["PDUtilDir/grid", "PDUtilDir/searchBlock", "PDUtilDir/slidebar"],
    function (Grid, SearchBlock, Slidebar) {

        function init(cache, searchObj, detailObj, closeObj, orderObj) {
            SearchBlock.init('searchBlockId');
            // 初始化
            return Grid({
                id: "AccountGirdDivId",
                pageSize: 10,
                index: true,
                multi: true,
                pagination: true,
                cache: false,
                layout: [
                    {
                        name: "团名称",
                        field: "groupName",
                        sort: true,
                        width: '250px',
                        click: function (e) {
                            detailObj.run(e.data.row.id);
                        }
                    },
                    {
                        name: "团编号",
                        field: "groupNo",
                        width: '160px',
                        sort: true
                    },
                    {
                        name: "团人数",
                        field: "personNum",
                        width: '70px',
                        sort: true
                    },
                    {
                        name: "总结算价",
                        width: '90px',
                        field: "totelCost",
                        sort: true
                    }, {
                        name: "总外卖价",
                        width: '90px',
                        field: "realSale",
                        sort: true
                    },
                    // {
                    // 	name : "实际费用",
                    // 	width: '90px',
                    // 	field : "realCost",
                    // 	sort : true
                    // },
                    {
                        name: "状态",
                        field: "status",
                        sort: true,
                        width: '60px',
                        format: function (e) {
                            return cache.statusMap.get(e.row.status);
                        }
                    },
                    {
                        name: "负责人",
                        width: '60px',
                        field: "chargePerson"
                    },
                    // {
                    // 	name : "负责人电话",
                    // 	field : "chargePersonPhone"
                    // },
                    {
                        name: "出团时间",
                        width: '140px',
                        field: "departureTime"
                    },
                    // {
                    // 	name : "回团时间",
                    // 	field : "goBackTime"
                    // },
                    {
                        name: "操作",
                        field: "createTime",
                        sort: false,
                        width: '160px',
                        format: function (e) {
                            var row = e.row, status = row.status, str = '';
//									str = '<a href="javascript:angular.element(\'#AccountGirdDivId\').scope().downSupport.run(\'' + e.row.id + '\')">封团</a>';
//									str += '<a href="javascript:angular.element(\'#AccountGirdDivId\').scope().orderSupport.run(\'' + e.row.id + '\')">下单</a>';
//									str += '<a href="javascript:angular.element(\'#AccountGirdDivId\').scope().assignSupport.run(\'' + e.row.id + '\')">指派导游</a>';
//									str += '<a href="javascript:angular.element(\'#AccountGirdDivId\').scope().backSupport.run(\'' + e.row.id + '\')">回团</a>';
//									str += '<a href="javascript:angular.element(\'#AccountGirdDivId\').scope().closeSupport.run(\'' + e.row.id + '\')">关闭</a>';
//									str += '<a href="javascript:angular.element(\'#AccountGirdDivId\').scope().leaderSupport.run(\'' + e.row.id + '\')">添加负责人</a>';
                            if (e.row.roleCode == 1)
                                str += '<a href="javascript:angular.element(\'#AccountGirdDivId\').scope().assignSupport.run(\'' + e.row.id + '\')">指派导游</a>';
                            else {
                                /*
                                 * 所处状态1
                                 *    未出团
                                 * 操作
                                 *    封团 指派导游
                                 */
                                if (status == "HCLV_TRAVEL_GROUP_STATUS_ISNO") {
                                    str += '<a href="javascript:angular.element(\'#AccountGirdDivId\').scope().downSupport.run(\'' + e.row.id + '\')">封团</a>';

                                    str += '<a href="javascript:angular.element(\'#AccountGirdDivId\').scope().leaderSupport.run(\'' + e.row.id + '\')">负责人</a>';
                                }
                                /*
                                 * 所处状态2
                                 *    出团
                                 * 操作
                                 *    下单 指派导游 回团
                                 */
                                if (status == "HCLV_TRAVEL_GROUP_STATUS_ISYES") {
                                    str += '<a href="javascript:angular.element(\'#AccountGirdDivId\').scope().openSupport.run(\'' + e.row.id + '\')">解封</a>';
                                    str += '<a href="javascript:angular.element(\'#AccountGirdDivId\').scope().orderSupport.run(\'' + e.row.id + '\')">下单</a>';
                                    str += '<a href="javascript:angular.element(\'#AccountGirdDivId\').scope().backSupport.run(\'' + e.row.id + '\')">回团</a>';
                                    str += '<a href="javascript:angular.element(\'#AccountGirdDivId\').scope().leaderSupport.run(\'' + e.row.id + '\')">负责人</a>';
                                }
                                /*
                                 * 所处状态3
                                 *    回团
                                 * 操作
                                 *    关闭团
                                 */
                                if (status == "HCLV_TRAVEL_GROUP_STATUS_ISBACK") {
                                    str += '<a href="javascript:angular.element(\'#AccountGirdDivId\').scope().closeSupport.run(\'' + e.row.id + '\')">关闭</a>';
                                }
                            }
                            return str;
                        }
                    }],
                toolbar: [/*
								 * { name : "封团", icon : "fa fa-search",
								 * callback : function(event) { closeObj.run(); } },
								 */{
                    name: "查询",
                    icon: "fa fa-search",
                    callback: function (event) {
                        searchObj.run();
                    }
                }],
                data: {
                    type: 'URL',
                    value: getServer()
                    // + '/flea/hclv/htravelGroup/listAllgroup.htmls'
                    + '/flea/hclv/htravelGroup/listmygroup.htmls'
                }
            });
        }

        return {
            init: init
        }
    });